package net.wisos.opn.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.CollectionTable;
import javax.persistence.JoinColumn;

import net.wisos.opn.account.entity.User;

@SuppressWarnings("serial")
@Entity
@Table(name = "sale_order")
public class Order extends BaseEntity {
	private String orderNo;
	private User customer;
	private List<OrderItem> items = new ArrayList<OrderItem>();
	private Date orderDate;

	/**
	 * @return the orderNo
	 */
	public String getOrderNo() {
		return orderNo;
	}

	/**
	 * @param orderNo
	 *            the orderNo to set
	 */
	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	/**
	 * @return the customer
	 */
	@ManyToOne
	@JoinColumn(name = "customer_id")
	public User getCustomer() {
		return customer;
	}

	/**
	 * @param customer
	 *            the customer to set
	 */
	public void setCustomer(User member) {
		this.customer = member;
	}

	/**
	 * @return the items
	 */
	@ElementCollection
	@CollectionTable(name = "order_item", joinColumns = @JoinColumn(name = "order_id"))
	public List<OrderItem> getItems() {
		return items;
	}

	/**
	 * @param items
	 *            the items to set
	 */
	public void setItems(List<OrderItem> items) {
		this.items = items;
	}

	/**
	 * @return the orderDate
	 */
	public Date getOrderDate() {
		return orderDate;
	}

	/**
	 * @param orderDate
	 *            the orderDate to set
	 */
	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}

}
